<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/2
 * Time: 15:19

/*$manager = new MongoDB\Driver\Manager('mongodb://localhost:27017');
$bulk = new MongoDB\Driver\BulkWrite;
$arr = [
    ['country' => '美国', 'num' => 11237, 'time' => time()],
    ['country' => '韩国', 'num' => 9123, 'time' => time()],
    ['country' => '俄罗斯', 'num' => 8123, 'time' => time()],
    ['country' => '日本', 'num' => 7123, 'time' => time()],
    ['country' => '阿尔巴尼亚', 'num' => 6123, 'time' => time()],
    ['country' => '德国', 'num' => 5123, 'time' => time()],
    ['country' => '法国', 'num' => 4123, 'time' => time()],
    ['country' => '日本', 'num' => 3123, 'time' => time()],
    ['country' => '中国台湾', 'num' => 1123, 'time' => time()],
    ['country' => '美国', 'num' => 1123, 'time' => time()],
];
foreach ($arr as $val) {
    $bulk->insert($val);
}

$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);//可选，修改确认
$res = $manager->executeBulkWrite('test.chain.top', $bulk, $writeConcern);
echo '<pre>';
print_r($res);
ini_set('date.timezone', 'Asia/Shanghai');
$now_hour = strtotime(date('Y-m-d H') . ':00:00');
echo date('Y-m-d H:i:s', $now_hour).PHP_EOL;
$last_day_hour = $now_hour - 24 * 60 * 60;
$arr = [];

for ($i = 48; $i >= 0; $i--) {
    $date_val = date('H:i', $now_hour - ($i * 30 * 60));
    array_push($arr, $date_val);
}
echo "<pre>";
//var_dump($arr);
echo "<pre>";
echo count($arr).PHP_EOL;
$data = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,34 ];
$avg = [];
$count = count($data)-1;
foreach ($data as $key => $val) {
    if ($key < $count) {
        $next_key = $key + 1;
        $next_val = $data[$next_key];
        $avg_val = ($val + $next_val) / 2;
        array_push($avg, $avg_val);
    }
}

$return = [];
foreach ($data as $k => $v) {
    array_push($return, $v);
    if (isset($avg[$k])) {
        array_push($return, $avg[$k]);
    }

}
echo "<pre>";
var_dump($return);
echo "<pre>";
$arr = [
	['毛衣', '外套'],
	['红色', '蓝色'],
	['xl','xxl']
];
$return =$row= [];
$left = $right = '';
for ($i =0; $i <count($arr); $i++) {
	
	foreach ($arr[$i] as $val) {
		if ($i == 0) {
			$row[] = $val;	
		} else {
			
			foreach ($row as $p) {
				static $p;
				$p = $p.$val;
				array_push($return, $p);
			}
		}
			
	}
}
var_dump($return);
$arr = [
	[1, 2, 3],
	[4, 5, 6],
	[7, 8, 9],
];
var_dump(sorts($arr));
function sorts($arr){
	$return =$row = [];
	
	for ($i = count($arr)-1;$i>=0; $i--) {
		$start =0;
		foreach ($arr[$i] as $key => $val) {
			$row[$start] = $val;
		}
		
		$return[] = $row;
		$start++;
	}
	p
	return $return;
}*/

//输出 3 的8次方
//getVal(3, 8);
//echo pow(3,8);
//function getVal($a, $b)
//{
//	$val = $a ;
//	for ($i = 1; $i < $b; $i++) {
//		$val *= $a;
//	}
//	var_dump($val);
//}
//echo json_encode(new stdClass);
echo -8%3;